const myArray = [1, 2, 3, 4, 5];

function shuffleArray(array) {
    for (let i = array.length - 1; i > 0; i--) {
        const j = Math.floor(Math.random() * (i + 1));
        // console.log(i + ":" + j)
        let temp = array[i]
        array[i] = array[j]
        array[j] = temp
        console.log([array[i], array[j]])
        // [array[i], array[j]] = [array[j], array[i]];
    }
    return array;
}

const newArray = shuffleArray(myArray);

console.log(newArray)